home *** CD-ROM | disk | FTP | other *** search
/ Tech Arsenal 1 / Tech Arsenal (Arsenal Computer).ISO / tek-01 / strlib.zip / STRRCHR.C < prev    next >
Text File  |  1993-01-04  |  896b  |  29 lines

  1.  
  2. /*  File   : strrchr.c
  3.     Author : Richard A. O'Keefe.
  4.     Updated: 10 April 1984
  5.     Defines: strrchr(), rindex()
  6.  
  7.     strrchr(s, c) returns a pointer to the  last  place  in  s  where  c
  8.     occurs,  or  NullS if c does not occur in s. This function is called
  9.     rindex in V7 and 4.?bsd systems; while not ideal the name is clearer
  10.     than strrchr, so rindex  remains  in  strings.h  as  a  macro.   NB:
  11.     strrchr  looks  for single characters, not for sets or strings.  The
  12.     parameter 'c' is declared 'int' so it will go in a register; if your
  13.     C compiler is happy with register char change it to that.
  14. */
  15.  
  16. #include "strings.h"
  17.  
  18. char *strrchr(s, c)
  19.     register _char_ *s;
  20.     register int c;
  21.     {
  22.         register char *t;
  23.  
  24.         t = NullS;
  25.         do if (*s == c) t = s; while (*s++);
  26.         return t;
  27.     }
  28.  
  29.